package org.netbeans.modules.qcubedpalette.qtextbox;

import org.netbeans.modules.qcubedpalette.QControl;
import org.netbeans.modules.qcubedpalette.QControlCustomizer;

public class QTextBox extends QControl {

	private String text;
	private QTextMode textMode;
	private boolean required;

	public QTextBox() {
		super();
	}

	public void setRequired(boolean required) {
		this.required = required;
	}

	public void setText(String text) {
		this.text = text;
	}

	public void setTextMode(QTextMode qtm) {
		this.textMode = qtm;
	}

	@Override
	protected String createMethod() {
		String method = "\nprotected function " + this.name + "_Create() {"
				+ "\n$this->" + this.name + " = new QTextBox($this);"
				+ "\n$this->" + this.name + "->Text = \"" + this.text + "\";";

		if (this.required) {
			method += "\n$this->" + this.name + "->Required = true;";
		}

		if (!this.textMode.equals(QTextMode.SINGLELINE)) {
			method += "\n$this->" + this.name + "->TextMode = QTextMode::" + this.textMode.GetQCodoString() + ";";
		}

		method += "\n}\n";

		return method;
	}

	@Override
	protected String createMethodCall() {
		return "\n$this->" + this.name + "_Create();\n";

	}

	@Override
	protected String createDataMember() {
		return "\nprotected $" + this.name + ";\n";
	}

	@Override
	protected QControlCustomizer getCustomizer() {
		return new QTextBoxCustomizer(this);
	}


}
